package it.text;

import it.domain.Movie;

import java.util.Scanner;

public class MovieText {

    private Movie[] movies;
    private Scanner sc = new Scanner(System.in);

    public MovieText(Movie[] movies) {
        this.movies = movies;
    }

    public void start(){
        lo:
        while (true) {
            System.out.println("----------电影信息系统----------");
            System.out.println("请输入您的选择:");
            System.out.println("1.查询全部电影信息");
            System.out.println("2.根据id查询电影信息");
            System.out.println("3.退出");

            int choice = sc.nextInt();
            switch (choice){
                case 1:
                    ShowAllInOne();
                    break;
                case 2:
                    ShowSelectIdTwo();
                    break;
                case 3:
                    System.out.println("感谢使用，退出！");
                    break lo;
                default:
                    System.out.println("输入序号错误，请检查！");
                    break;

            }
        }


    }

    private void ShowSelectIdTwo() {
        System.out.println("请输入要查看的电影编号:");
        int id = sc.nextInt();
        for (int i = 0; i < movies.length; i++) {
            if (movies[i].getId() == id) {
                System.out.println(movies[i].getTitle()+"---"
                        +movies[i].getTime()+"---"+movies[i].getScore()+"---"
                        +movies[i].getArae()+"---"+movies[i].getType()+"---"
                        +movies[i].getScore()+"---"+movies[i].getArae()+"---"
                        +movies[i].getType());
                return;
            }

        }
        System.out.println("编号没有对应的电影！可重新输入！");

    }

    private void ShowAllInOne() {
        for (int i = 0; i < movies.length; i++) {
            System.out.println(movies[i].getTitle()+"---"+movies[i].getScore());
        }

    }


}
